import { BasicColumn, FormSchema } from '@/components/Table';
import { h, ref } from 'vue';
import { Tag } from 'ant-design-vue';
import {VxeFormItemProps, VxeGridPropTypes} from "@/components/VxeTable";
import util from "@/utils/util";
import { deptSelectList,shelfSelectList } from '@/api/sys/iot';


/**
 */
export const vxeTableColumns: VxeGridPropTypes.Columns = [
  {
    title: '仓库名称',
    field: 'houseStoreName',
    showOverflow: 'title',
    align: 'center',
    width:120
  },
  {
    title: '库位名称',
    field: 'houseLocationName',
    showOverflow: 'title',
    align: 'center',
    width:120
  },


  {
    title: '标签mac',
    field: 'tagMac',
    align: 'center',
    width: 150,
  },
  {
    title: '标签类型',
    field: 'tagType',
    align: 'center',
    width: 120,
  },
  {
    title: '亮灯状态',
    field: 'status',
    align: 'center',
    width: 150,
    slots:{
      default: ({ row }) => {
        const type = row.status;
        let text = '';
        let color="";
        switch (type) {
          case 1:
            text = '亮灯';
            color="green";
            break;
          case 0:
            color="red";
            text = '灭灯';
            break;
        }
        // return text;
        return h(Tag, {color}, () => text);
      },
    }
  },
  {
    title: '架子Mac',
    field: 'shelfMac',
    showOverflow: 'title',
    align: 'center',
    width: 120,
  },
  {
    title: '排序',
    field: 'sort',
    align: 'center',
    width: 120,
  },
  {
    title: '创建时间',
    field: 'createTime',
    width: 130,
    align: 'center',
  },

  {
    // width: 300,
    title: '操作',
    align: 'center',
    field: '',
    slots: { default: 'action' },
    fixed: 'right',
  },
];




export const vxeTableFormSchema: VxeFormItemProps[] = [
  {
    span: 5,
    field: 'keyword',
    title: '搜索',
    itemRender: {
      props: {
        placeholder: '标签编号',
      },
      name: 'AInput',
    },
  },
  {
    span: 5,
    field: 'tagType',
    title: '标签类型',
    itemRender: {
      props: {
        options: [
          {label:"小灯",value:"小灯"},
          {label:"巷道灯",value:"巷道灯"},
        ]
      },
      name: 'VxeSelect',
    },
  },
  {
    span: 5,
    field: 'status',
    title: '亮灯状态',
    itemRender: {
      props: {
        options: [
          {label:"亮灯",value:1},
          {label:"灭灯",value:0},
        ]
      },
      name: 'VxeSelect',
    },
  },
  {
    span: 5,
    itemRender: {
      name: 'VxeButtonGroup',
      options: [
        { type: 'reset', content: '重置' },
        { type: 'submit', content: '查询', status: 'primary' },
      ],
    },
  },
];


export const formSchema: FormSchema[] = [
  {
    field: 'houseLocationId',
    label: 'houseLocationId',
    component:"Input",
    required: false,
  },
  {
    field: 'shelfMac',
    label: '架子Mac',
    component:"Input",
    required: false,
  },
  {
    field: 'tagType',
    label: '标签型号',
    component:"Input",
    required: true,
  },
  {
    field: 'tagMac',
    label: '标签mac',
    component:"Input",
    required: true,
  },
  {
    field: 'sort',
    label: '排序',
    component:"InputNumber",
    required: false,
  },

];
